/**
 * @author DongPing
 * 2022/1/12 11:09
 *
 * 资产卡片按钮和弹窗弹窗
 *
 * */
import {useEffect, useState} from "react";
import {Button, Modal} from "antd";
import {DisplayTableByMetas, getAllTypesOfMetasByPageCode} from "@/biz-components/claim-items/components";
import { formatMessage } from '@/utils/i18n-transform';

// 资产卡片的元模型页面编码
const PAGE_CODE = 'AssetCard_Modal_L';

export function AssetCard(props: {
	data: any[]
}) {
	const [visible, setVisible] = useState(false);
	const {data = []} = props;
	const [tableMetas, setTableMetas] = useState<any[]>([]);
	useEffect(function () {
		getAllTypesOfMetasByPageCode(PAGE_CODE).then((result) => {
			setTableMetas(result.tableColumnMetas);
		})
	}, []);

	return (
		<>
			<Button size={"small"} onClick={() => {
				setVisible(true);
			}}>{formatMessage({id: 'others.assetCard'})}</Button>
			<Modal width={800} visible={visible} onCancel={() => setVisible(false)} footer={null} title={formatMessage({id: 'others.assetCard'})}>
				<DisplayTableByMetas metas={tableMetas} data={data}/>
			</Modal>
		</>
	)
}

